from configs.flask_id2name import id2name


def thresh_model(opt):
    single_conf = True
    conf = opt['conf_thres']
    if type(conf) is not list:
        conf = 6 * [conf]

    if show_choice['face']:
        face_conf = opt['face_conf_thres']
        conf = [min(conf[i], face_conf[i]) for i in range(len(face_conf))]
        single_conf = False

    if show_choice['body']:
        body_conf = opt['body_conf_thres']
        conf = [min(conf[i], body_conf[i]) for i in range(len(body_conf))]
        single_conf = False

    if show_choice['bottom']:
        bottom_conf = opt['bottom_conf_thres']
        conf = [min(conf[i], bottom_conf[i]) for i in range(len(bottom_conf))]
        single_conf = False

    opt['thresh_model'] = conf
    if not single_conf:
        opt['conf_thres'] = min(conf)


if __name__ == '__main__':
    opt = {'face': True,
              'body': False,
              'bottom': True,
              'conf_thres': 0.2,
              'face_conf_thres': [0.1, 0.2, 0.31, 0.12, 0.11, 0.2],
              'bottom_conf_thres': [0.1, 0.12, 0.3, 0.13, 0.435, 0.2]
              }
    show_choice = {
        "face": opt['face'],
        "body": opt['body'],
        "bottom": opt['bottom'],
    }
    thresh_model(opt)
    print(opt['thresh_model'])
    print(opt['conf_thres'])
